/**
* 作者 ：食草狂魔
*
* 日期 ：2017/11/30
*
* 描述 ：目录管理组件 - 查看信息项
*/
<template>
  <div class="dialogContent">
    <el-form :model="ruleForm" label-position="right" label-width="110px">
      <el-form-item label="信息项名称 :" prop="name">
        <p>{{ruleForm.name}}</p>
      </el-form-item>
      <el-row>
        <el-col :span="12">
          <el-form-item label="数据类型 :">
            <p>{{ ruleForm.infoPropertyDataTypeName }}</p>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="数据长度 :">
            <p>{{ ruleForm.dataLength }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="dialogBar">
        <el-col class="title">共享属性</el-col>
      </el-row>
      <el-row style="margin-top: 20px;">
        <el-col :span="12">
          <el-form-item label="共享类型 :">
            <!--zijilai-->
            <p v-if="ruleForm.shareType==1">不共享</p>
            <p v-if="ruleForm.shareType==2">有条件共享</p>
            <p v-if="ruleForm.shareType==3">无条件共享</p>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="共享方式 :">
            <p>{{ ruleForm.infoPropertyShareModeName }}</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="共享条件 :">
        <p>{{ ruleForm.shareContent }}</p>
      </el-form-item>
      <el-row class="dialogBar">
        <el-col class="title">开放属性</el-col>
      </el-row>
      <el-row style="margin-top: 20px;">
        <el-col :span="12">
          <el-form-item label="开放类型 :">
            <!--ziji-->
            <p v-if="ruleForm.isOpen==1">不开放</p>
            <p v-if="ruleForm.isOpen==2">有条件开放</p>
            <p v-if="ruleForm.isOpen==3">无条件开发</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="开放条件 :">
        <p>{{ ruleForm.openContent }}</p>
      </el-form-item>
      <el-row>
        <el-col :span="12">
          <el-form-item label="发布日期 :">
            <p>{{ ruleForm.releaseTime }}</p>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="发布周期 :">
            <!--自己来-->
            <p v-if="ruleForm.updateCycle==1">实时</p>
            <p v-if="ruleForm.updateCycle==2">每日</p>
            <p v-if="ruleForm.updateCycle==3">每周</p>
            <p v-if="ruleForm.updateCycle==4">每季</p>
            <p v-if="ruleForm.updateCycle==5">每半年</p>
            <p v-if="ruleForm.updateCycle==6">每年</p>
            <p v-if="ruleForm.updateCycle==7">其他</p>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row class="dialogBar">
        <el-col class="title">备注</el-col>
      </el-row>
      <el-form-item prop="sharePre" class="addRemarks">
        <p>{{ ruleForm.description }}</p>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
  import dirAPIs from '../../../../api/dirAPIs'
  export default {
    props: ["parentModel", "updateFormData"],
    name: "showCatalogForm",
    data () {
      return {
        ruleForm: {
          name: this.$props.updateFormData.propertyName, //信息项名称
          infoPropertyDataTypeName: this.$props.updateFormData.infoPropertyDataTypeName, // 数据类型
          dataLength: this.$props.updateFormData.propertyDataLength, // 数据长度
          shareType: this.$props.updateFormData.shareType, // 共享类型
          shareMode1: "",
          infoPropertyShareModeName: this.$props.updateFormData.infoPropertyShareModeName, // 共享方式
          shareContent: this.$props.updateFormData.shareContent, // 共享条件
          isOpen: this.$props.updateFormData.isOpen,
          openContent: this.$props.updateFormData.openContent, // 开放条件内容
          releaseTime: new Date(parseInt(this.$props.updateFormData.releaseTime)).toLocaleDateString(), // 发布时间
          updateCycle: this.$props.updateFormData.updateCycle, // 发布周期
          description: this.$props.updateFormData.description,  // 备注
          infoResourceId: this.$props.parentModel.infoResourceId
        },
        dataTypeList: [],
        dataLength: [{
          value: "50",
          label: "50"
        },{
          value: "100",
          label: "100"
        },{
          value: "200",
          label: "200"
        },{
          value: "300",
          label: "300"
        },{
          value: "400",
          label: "400"
        }],
        shareTypeList:[{
          value: "1",
          label: "不共享"
        },{
          value: "2",
          label: "有条件共享"
        },{
          value: "3",
          label: "无条件共享"
        }],
        shareTypeList1: [],
        shareTypeList2: [],
        updateCycleList: [{
          value: "1",
          label: "实时"
        },{
          value: "2",
          label: "每日"
        },{
          value: "3",
          label: "每周"
        },{
          value: "4",
          label: "每季度"
        },{
          value: "5",
          label: "每半年"
        },{
          value: "6",
          label: "每年"
        },{
          value: "7",
          label: "其他"
        }],
        openTypeList: [{
          value: "1",
          label: "不开放"
        },{
          value: "2",
          label: "有条件开放"
        },{
          value: "3",
          label: "无条件开放"
        }]
      }
    },
    mounted: function () {
      let vm = this

      // 加载数据类型数据
      vm.loadDataType()

      // 加载共享方式数据
      vm.loadShareType(0)
    },
    methods: {
      changeShareType (val) {
        let vm = this
        vm.loadShareType(val)
      },
      loadDataType () {
        let vm = this
        dirAPIs.getInfoPropertyDateTypes({
          token: localStorage.token
        }).then(({ data }) => {
          vm.dataTypeList = data.data
        })
      },
      loadShareType (parentId) {
        let vm = this
        dirAPIs.getInfoPropertyShareModes({
          token: localStorage.token,
          infoPropertyShareModeId: parentId
        }).then(({ data }) => {
          if(data.code == 10000) {
            if(parentId!=0){
              vm.shareTypeList2 = data.data
            }
            else{
              vm.shareTypeList1 = data.data
            }
          }
        })
      }
    }
  }
</script>
<style>
  /*弹窗*/
  .dialogContent .dialogBar{
    height: 35px;
    line-height: 35px;
    background-color: #ebebeb;
    border-left: 4px solid #2cace2;
    text-align: left;
    width: 97%;
    margin: 0 auto;
  }
  .dialogContent .dialogBar .title{
    margin-left: 10px;
    color: #2cace2;
    font-size: 1.8rem;
  }
  .dialogContent .inputControl {
    width: 90%;
  }
  .dialogContent .longText {
    width: 96%;
  }
  .dialogContent .button{
    width: 120px;
  }
  .dialogContent button:first-child{
    margin-right: 60px;
  }
  .dialogContent .addRemarks{
    width: 97%;
    margin: 0 auto;
  }
  .dialogContent .addRemarks .el-form-item__content{
    margin:20px 0 0 0 !important;
  }
</style>
